$OpenBSD: patch-configure_in,v 1.5 2015/08/11 21:13:14 sthen Exp $
--- configure.in.orig	Thu Apr 17 22:55:38 2014
+++ configure.in	Thu Jul 30 16:52:11 2015
@@ -413,14 +413,14 @@ AC_ARG_WITH(uds,
 			    AC_TRY_COMPILE([#include <sys/types.h>
 				    #include <sys/socket.h>],
 				    [
-struct ucred u;
+struct sockpeercred u;
 u.uid = 0;
 #if !defined(SO_PEERCRED)
 #error "no SO_PEERCRED defined"
 #endif
 				    ],
 				    [AC_MSG_RESULT(yes)
-				     AC_DEFINE(UDS_CRED_STYPE, ucred, [Defined to UDS credential structure name])
+				     AC_DEFINE(UDS_CRED_STYPE, sockpeercred, [Defined to UDS credential structure name])
 				     AC_DEFINE(UDS_CRED_UID, uid, [Defined to UDS credential structure uid field])
 				     AC_DEFINE(UDS_CRED_SO, SO_PEERCRED, [Defined to UDS credential socket option])
 				     AC_DEFINE(TRUST_UDS_CRED)],
@@ -428,18 +428,34 @@ u.uid = 0;
 					AC_TRY_COMPILE([#include <sys/types.h>
 						#include <sys/socket.h>],
 						[
+struct ucred u;
+u.euid = 0;
+#if !defined(SO_PEERCRED)
+#error "no SO_PEERCRED defined"
+#endif
+						],
+				    		[AC_MSG_RESULT(yes)
+				     		AC_DEFINE(UDS_CRED_STYPE, ucred, [Defined to UDS credential structure name])
+				     		AC_DEFINE(UDS_CRED_UID, uid, [Defined to UDS credential structure uid field])
+				     		AC_DEFINE(UDS_CRED_SO, SO_PEERCRED, [Defined to UDS credential socket option])
+				     		AC_DEFINE(TRUST_UDS_CRED)],
+						[
+							AC_TRY_COMPILE([#include <sys/types.h>
+								#include <sys/socket.h>],
+								[
 struct peercred_struct u;
 u.euid = 0;
 #if !defined(SO_PEERID)
 #error "no SO_PEERID defined"
 #endif
-						],
-						[AC_MSG_RESULT(yes)
-						 AC_DEFINE(UDS_CRED_STYPE, peercred_struct, [Defined to UDS credential structure name])
-						 AC_DEFINE(UDS_CRED_UID, euid, [Defined to UDS credential structure uid field])
-						 AC_DEFINE(UDS_CRED_SO, SO_PEERID, [Defined to UDS credential socket option])
-						 AC_DEFINE(TRUST_UDS_CRED)],
-						[AC_MSG_RESULT(no)])
+								],
+								[AC_MSG_RESULT(yes)
+								 AC_DEFINE(UDS_CRED_STYPE, peercred_struct, [Defined to UDS credential structure name])
+								 AC_DEFINE(UDS_CRED_UID, euid, [Defined to UDS credential structure uid field])
+								 AC_DEFINE(UDS_CRED_SO, SO_PEERID, [Defined to UDS credential socket option])
+								 AC_DEFINE(TRUST_UDS_CRED)],
+								[AC_MSG_RESULT(no)]),
+						    ])
 				    ])
 			    ;;
 			*)
@@ -653,27 +669,26 @@ AC_ARG_WITH(freeipmi,
 		FREEIPMILDFLAGS="-L$withval/lib -R$withval/lib"
 	    fi
 	else
-	    FREEIPMICPPFLAGS=""
-	    FREEIPMILDFLAGS=""
+	    FREEIPMICPPFLAGS="`pkg-config --cflags libfreeipmi`"
+	    FREEIPMILDFLAGS="`pkg-config --libs libfreeipmi`"
 	fi
 
 	oCPPFLAGS="$CPPFLAGS"
 	oLDFLAGS="$LDFLAGS"
 	oLIBS="$LIBS"
 	have_freeipmi=no
-
 	CPPFLAGS="$CPPFLAGS $FREEIPMICPPFLAGS"
 	LDFLAGS="$LDFLAGS $FREEIPMILDFLAGS"
 
 	AC_CHECK_HEADER([ipmiconsole.h],
-	    [LIBS="$LIBS -lipmiconsole"
+	    [LIBS="$LIBS `pkg-config --libs libipmiconsole`"
 	    AC_MSG_CHECKING(for freeipmi libraries -lipmiconsole)
 	    AC_TRY_LINK([#include <ipmiconsole.h>
 		],[ipmiconsole_ctx_fd(0)],
 		[AC_MSG_RESULT(yes)
 		cons_with_freeipmi="YES"
 		AC_DEFINE(HAVE_FREEIPMI)
-		CONSLIBS="$CONSLIBS -lipmiconsole"
+		CONSLIBS="$CONSLIBS `pkg-config --libs libipmiconsole`"
 		have_freeipmi=yes],
 		[AC_MSG_RESULT(no)])],)
 
